# -*- coding:UTF-8 -*-
from __future__ import annotations

class R:
    def __init__(self, code=0, msg='', data={}):
        self.code = code
        self.msg = msg
        self.data = data

    @classmethod
    def success(cls, data={}):
        return cls(code=0, msg='success', data=data)

    @classmethod
    def error(cls, code=1, msg='error', data={}):
        return cls(code=code, msg=msg, data=data)

    @classmethod
    def fail(cls, code=1, msg='fail', data={}):
        return cls(code=code, msg=msg, data=data)

    def setCode(self, code) -> R:
        self.code = code
        return self

    def setMsg(self, msg='') -> R:
        self.msg = msg
        return self

    def setData(self, data={}) -> R:
        self.data = data
        return self